package com.wang.strategy;



import com.wang.client.RpcClient;

import java.util.Map;

/**
 * zk多机负载均衡策略(单机)
 */
public class DefaultLoadBalanceStrategy implements LoadBalanceStrategy {

    @Override
    public RpcClient getClient(Map<String, RpcClient> rpcClientMap) {
        if (rpcClientMap == null || rpcClientMap.size() == 0) {
            return null;
        }
        //取到第一个rpcClient直接返回
        for (Map.Entry<String, RpcClient> entry : rpcClientMap.entrySet()) {
            if (entry.getValue() != null) {
                return entry.getValue();
            }
        }
        return null;
    }
}
